package main

import (
	"fmt"
	"gitee.com/venki/go_study_accumulate/go_code/20210824/closure"

	"gitee.com/venki/go_study_accumulate/go_code/20210824/api"
	// "go_code/20210824/closure"
)

func main() {
	closureModule()
	// gotoModule()
	// continueModule()
	// breakModule()
	// apiModuleAboutForKey()
	// apiModuleAbout()
}

func closureModule() {
	module := closure.Closure
	fmt.Println(module)
}

func sumModule(num1 int, num2 int) int {
	var sum int = 0
	sum += num1
	sum += num2
	return sum
}

func gotoModule() {
	fmt.Println("hello golang1")
	fmt.Println("hello golang2")
	goto lable2
	fmt.Println("hello golang3")
	fmt.Println("hello golang4")
	fmt.Println("hello golang5")
	fmt.Println("hello golang6")
lable2:
	fmt.Println("hello golang7")
	fmt.Println("hello golang8")
}

func continueModule() {
	for i := 1; i <= 100; i++ {
		/*if i%6 == 0 {
			fmt.Println(i)
		}*/
		if i%6 != 0 {
			continue
		}
		fmt.Println(i)
	}
}

func breakModule() {
	var sum int = 0
	for i := 1; i <= 100; i++ {
		sum += i
		fmt.Println(sum)
		if sum >= 300 {
			break
		}
	}
	fmt.Println(sum)
}

func apiModuleAboutForKey() {
	var str string = "hello golang你好"
	/*for i := 0; i < len(str); i++ {
		fmt.Printf("%c\n", str[i])
	}*/
	for i, value := range str {
		fmt.Printf("索引为：%d，具体的值是：%c\n", i, value)
	}
}

func apiModuleAbout() {
	fmt.Println(api.Name)
}
